<!DOCTYPE html>
<html lang="zh-hans">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <script src="./src/vue.global.js"></script> -->
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.1.5/vue.global.js"></script>
    <style>
        .demo {
            font-family: sans-serif;
            border: 1px solid #eee;
            border-radius: 2px;
            padding: 20px 30px;
            margin-top: 1em;
            margin-bottom: 40px;
            user-select: none;
            overflow-x: auto;
        }
    </style>
</head>
<body>
    <div id="blog-posts-events-demo" class="demo">
        <div :style="{ fontSize: postFontSize + 'em' }">
            <blog-post v-for="post in posts" :key="post.id" :title="post.title" @enlarge-text="big"></blog-post>
        </div>
    </div>
    <script>
        const app = Vue.createApp({
            data() {
                return {
                    posts: [{
                            id: 1,
                            title: 'My journey with Vue'
                        },
                        {
                            id: 2,
                            title: 'Blogging with Vue'
                        },
                        {
                            id: 3,
                            title: 'Why Vue is so fun'
                        }
                    ],
                    postFontSize: 1
                }
            },
            methods: {
                big() {
                    this.postFontSize += 0.1
                }
            }
        })

        app.component('blog-post', {
            props: ['title'],
            methods: {
                scale(props) {
                    console.log(props)
                    this.$emit('enlargeText')
                }
            },
            template: `
    <div class="blog-post">
      <h4>{{ title }}</h4>
      <button @click="scale(1)">
        Enlarge text
      </button>
    </div>
  `
        })

        app.mount('#blog-posts-events-demo')
    </script>
</body>
</html>